package com.sojson.service.impl;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sojson.dao.HelpRecordDao;
import com.sojson.entity.po.HelpRecord;
import com.sojson.service.HelpRecordService;
import com.sojson.util.token.TokenUtil;

/**
 * 优惠券助力表Service实现类
 * 
 * @author liu
 * @date 2021-03-24
 */
@Service
public class HelpRecordServiceImpl implements HelpRecordService {

    @Resource
    private HelpRecordDao helpRecordDaoImpl;

    /**
     * 单条插入
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(HelpRecord helpRecord) {
        int insert = helpRecordDaoImpl.insert(helpRecord);
        return insert;
    }

    /**
     * 批量插入
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(HelpRecord helpRecord) {
        int insertList = helpRecordDaoImpl.insertList(helpRecord.getHelpRecords());
        return insertList;
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(HelpRecord helpRecord) {
        int deleteByDto = helpRecordDaoImpl.deleteByDto(helpRecord);
        return deleteByDto;
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() {
        int countAll = helpRecordDaoImpl.countAll();
        return countAll;
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<HelpRecord> findAll() {
        List<HelpRecord> findAll = helpRecordDaoImpl.listAll();
        return findAll;
    }

    /**
     * 根据对象统计数量
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(HelpRecord helpRecord) {
        int countByDto = helpRecordDaoImpl.countByDto(helpRecord);
        return countByDto;
    }

    /**
     * 根据对象查询
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public List<HelpRecord> findByDto(HelpRecord helpRecord) {
        List<HelpRecord> findByDto = helpRecordDaoImpl.listByDto(helpRecord);
        return findByDto;
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteById(Integer id) {
        int deleteById = helpRecordDaoImpl.deleteById(id);
        return deleteById;
    }

    /**
     * 通过id列表删除(物理删除)
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByIdList(List<Integer> ids) {
        int deleteByIdList = helpRecordDaoImpl.deleteByIdList(ids);
        return deleteByIdList;
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int updateById(HelpRecord helpRecord) {
        int updateById = helpRecordDaoImpl.updateById(helpRecord);
        return updateById;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByIdList(HelpRecord helpRecord) {
        int updateStaticByIdList = helpRecordDaoImpl.updateStaticByIdList(helpRecord);
        return updateStaticByIdList;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByIdList(HelpRecord helpRecord) {
        int updateChangeByIdList = helpRecordDaoImpl.updateChangeByIdList(helpRecord.getHelpRecords());
        return updateChangeByIdList;
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialById(HelpRecord helpRecord) {
        int updatePartialById = helpRecordDaoImpl.updatePartialById(helpRecord);
        return updatePartialById;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByIdList(HelpRecord helpRecord) {
        int updateStaticPartialByIdList = helpRecordDaoImpl.updateStaticPartialByIdList(helpRecord);
        return updateStaticPartialByIdList;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByIdList(HelpRecord helpRecord) {
        int updateChangePartialByIdList = helpRecordDaoImpl.updateChangePartialByIdList(helpRecord.getHelpRecords());
        return updateChangePartialByIdList;
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public HelpRecord findById(Integer id) {
        HelpRecord findById = helpRecordDaoImpl.findById(id);
        return findById;
    }

    /**
     * 通过id列表查询
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public List<HelpRecord> findByIdList(List<Integer> ids) {
        List<HelpRecord> findByIdList = helpRecordDaoImpl.findByIdList(ids);
        return findByIdList;
    }

    /**
     * 通过对象查询id列表
     * 
     * @param helpRecord
     * @return
     * @throws SQLException
     */
    @Override
    public List<Integer> findIdByDto(HelpRecord helpRecord) {
        List<Integer> findIdByDto = helpRecordDaoImpl.findIdByDto(helpRecord);
        return findIdByDto;
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() {
        helpRecordDaoImpl.clear();
    }

    /**
     * 根据对象查询头像
     * 
     * @param helpRecord
     * @return
     * @throws IOException 
     * @throws SQLException
     */
    @Override
    public List<String> findThisHeadImg(HelpRecord helpRecord) throws IOException {
        String userNo = TokenUtil.getUserNo();
        helpRecord.setUserNo(userNo);
        return helpRecordDaoImpl.findHeadImg(helpRecord);
    }

}